jQ(document).ready(function(){
	jQ("div.my_clips_menu a.clipindex").addClass("clipindexonit");
	jQ("input.hminput").val(0);
	buildFun();
	fun_scroll();
	getDayEventsByToday();
	getEventsByInviting();
});
function detailClipEvent(obj){
	var eventid=jQ("#td_box_eventid").val();
	window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
}
function prevMonthClick(){
	getMonthEventsByPrototype("dayAjax!getPrevMonth.action");
}
function prevDayClick(){
	getMonthEventsByPrototype("dayAjax!getPrevDay.action");
}
function changeDayView(){
	getMonthEventsByPrototype("dayAjax!getUserDefinedDay.action");
}
function nextDayClick(){
	getMonthEventsByPrototype("dayAjax!getNextDay.action");
}
function nextMonthClick(){
	getMonthEventsByPrototype("dayAjax!getNextMonth.action");
}
function getDayEventsByToday(){
	getMonthEventsByPrototype("dayAjax!getThisDay.action");
}
function getMonthEventsByPrototype(url){
	var year = jQ("#mouth_fun_weekview_year").val();
	var month = jQ("#mouth_fun_weekview_month").val();
	var day = jQ("#mouth_fun_weekview_day").val();
	jQ.ajax({
		type : "POST",
		url : url,
		data:{
			year : year,
			month : month,
			day : day
		},
		success:function(data){
			var jsonobj = eval("("+data+")");
			var _select_day = jQ("#mouth_fun_weekview_day").empty();
			for(var i=0;i<jsonobj.maxday;i++){
				_select_day.append("<option value='"+(i+1)+"'>"+(i+1)+"</option>");
			}
			jQ("#mouth_fun_weekview_year").val(jsonobj.year);
			jQ("#mouth_fun_weekview_month").val(jsonobj.month);
			jQ("#mouth_fun_weekview_day").val(jsonobj.day);
			getEventsByDay(jsonobj.year,jsonobj.month,jsonobj.day);
		}
	});
}
function getEventsByDay(year,month,day){
	jQ.ajax({
		type: "POST",
		url:"dayAjax!getEventsByDay.action",
		data:{
			year : year,
			month : month,
			day : day
		},
		success:function(data){
			orgEventsToMonthViewData(data);
		}
	});
}
function orgEventsToMonthViewData(data){
	var htmlshare="";
	var htmljoin="";
	var sharearray=new Array();
	var joinarray=new Array();
	if(jQ(data).find("EventForView").length==0){
		noeventInCenter();
		return;
	}
	jQ(data).find("EventForView").each(function(){
		var reliedclip=eval(jQ(this).find("reliedclip").text());
		var id=eval(jQ(this).attr("id"));
		var startday=eval(jQ(this).find("startday").text());
		var endday=eval(jQ(this).find("endday").text());
		
		if(reliedclip>0){ //my_join
			var canbeadded=false;
			for(var i=0;i<joinarray.length;i++){
				var arr=joinarray[i];
				var flag=true;
				for(var j=startday;j<=endday-1;j++){
					if(arr[j]!=0){
						flag=false;
						break;
					}
				}
				if(flag){
					for(var j=startday;j<=endday-1;j++){
						arr[j]=id;
					}
					canbeadded=true;
					break;
				}
			}
			if(!canbeadded){
				var length=joinarray.length;
				joinarray[length]=new Array();
				 
				for(var j=0;j<24;j++){
					if(j>=startday&&j<=endday-1){
						joinarray[length][j]=id;
					}else{
						joinarray[length][j]=0;
					}
				}
			}
			
		}else{ //my_share
			var canbeadded=false;
			for(var i=0;i<sharearray.length;i++){
				var arr=sharearray[i];
				var flag=true;
				for(var j=startday;j<=endday-1;j++){
					if(arr[j]!=0){
						flag=false;
						break;
					}
				}
				if(flag){
					for(var j=startday;j<=endday-1;j++){
						arr[j]=id;
					}
					canbeadded=true;
					break;
				}
			}
			if(!canbeadded){
				var length=sharearray.length;
				sharearray[length]=new Array();
				for(var j=0;j<24;j++){
					if(j>=startday&&j<=endday-1){
						sharearray[length][j]=id;
					}else{
						sharearray[length][j]=0;
					}
				}
			}
		}
	});
	
	if(sharearray.length>0&&joinarray.length>0){
		jQ("#joinclip").addClass("hasshare");
		jQ("#crtclip").parent().addClass("hasjoin");
	}else{
		jQ("#joinclip").removeClass("hasshare");
		jQ("#crtclip").parent().removeClass("hasjoin");
	}
	
	for ( var i = 0; i < joinarray.length; i++) {
		var arr=joinarray[i];
		htmljoin+= "<tr>";
		for ( var j = 0; j < 24; j++) {
			var id=arr[j];
			if(id==0){
				htmljoin+="<td class='invite_event noevent' title='双击立即添加档期' hour="+j+"><div class='noevent'></div></td>";
			}else{
				var obj=jQ(data).find("EventForView[id='"+id+"']");
				var processstatus=eval(jQ(obj).find("processstatus").text());
				var id=eval(jQ(obj).attr("id"));
				var title=jQ(obj).find("title").text();
				var eventtype=jQ(obj).find("eventtype").text();
				var startday=eval(jQ(obj).find("startday").text());
				var endday=eval(jQ(obj).find("endday").text());
				
				htmljoin+="<td id='clipevent-"+id+"' class='invite_event my_join hasevent' hour="+startday+" colspan='"+(endday-startday)+"'>";
				htmljoin+="<div class='hasevent'>";
				if(processstatus==2)
					htmljoin+="<a class='stop filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				else
					htmljoin+="<a class='"+eventtype+" filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				j=endday-1;
			}
		}
		htmljoin+= "</tr>";
	}
	for ( var i = 0; i < sharearray.length; i++) {
		var arr=sharearray[i];
		htmlshare+= "<tr>";
		for ( var j = 0; j < 24; j++) {
			var id=arr[j];
			if(id==0){
				htmlshare+="<td class='invite_event noevent' title='双击立即添加档期' hour="+j+"><div class='noevent'></div></td>";
			}else{
				var obj=jQ(data).find("EventForView[id='"+id+"']");
				var processstatus=eval(jQ(obj).find("processstatus").text());
				var id=eval(jQ(obj).attr("id"));
				var title=jQ(obj).find("title").text();
				var eventtype=jQ(obj).find("eventtype").text();
				var startday=eval(jQ(obj).find("startday").text());
				var endday=eval(jQ(obj).find("endday").text());
				
				htmlshare+="<td id='clipevent-"+id+"' class='invite_event my_share hasevent' hour="+startday+" colspan='"+(endday-startday)+"'>";
				htmlshare+="<div class='hasevent'>";
				if(processstatus==2)
					htmlshare+="<a class='stop filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				else
					htmlshare+="<a class='"+eventtype+" filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
				j=endday-1;
			}
		}
		htmlshare+= "</tr>";
	}
	jQ("#crtclip").nextAll().remove();
	jQ("#crtclip").after(htmlshare);
	jQ("#joinclip").empty().append(htmljoin);
	jQ(data).find("EventForView").each(function(){
		var reliedclip=eval(jQ(this).find("reliedclip").text());
		var processstatus=eval(jQ(this).find("processstatus").text());//
		var id=eval(jQ(this).attr("id"));//
		var title=jQ(this).find("title").text();//
		var eventtype=jQ(this).find("eventtype").text();
		var starttime=eval(jQ(this).find("starttime").text());
		var endtime=eval(jQ(this).find("endtime").text());
		var iswholeday=eval(jQ(this).find("iswholeday").text());
		var address=jQ(this).find("address").text();
		var content=jQ(this).find("content").text();
		var clocktime=eval(jQ(this).find("clocktime").text());
		var deadlinetime=eval(jQ(this).find("deadlinetime").text());
		var isvip=eval(jQ(this).find("isvip").text());
		var publishname=jQ(this).find("publishname").text();
		var forwardname=jQ(this).find("forwardname").text();
		var puid=jQ(this).find("puid").text();
		var fuid=jQ(this).find("fuid").text();
		var cliptype=jQ(this).find("cliptype").text();
		jQ("#clipevent-"+id).data("eventid",id);
		jQ("#clipevent-"+id).data("title",title);
		jQ("#clipevent-"+id).data("eventtype",eventtype);
		jQ("#clipevent-"+id).data("starttime",starttime);
		jQ("#clipevent-"+id).data("endtime",endtime);
		jQ("#clipevent-"+id).data("iswholeday",iswholeday);
		jQ("#clipevent-"+id).data("address",address);
		jQ("#clipevent-"+id).data("content",content);
		jQ("#clipevent-"+id).data("clocktime",clocktime);
		jQ("#clipevent-"+id).data("deadlinetime",deadlinetime);
		jQ("#clipevent-"+id).data("isvip",isvip);
		jQ("#clipevent-"+id).data("processstatus",processstatus);
		jQ("#clipevent-"+id).data("reliedclip",reliedclip);
		jQ("#clipevent-"+id).data("publishname",publishname);
		jQ("#clipevent-"+id).data("forwardname",forwardname);
		jQ("#clipevent-"+id).data("puid",puid);
		jQ("#clipevent-"+id).data("fuid",fuid);
		jQ("#clipevent-"+id).data("cliptype",cliptype);
	});
	effectEventDetail();
}


function effectEventDetail(){
	jQ("td.noevent").unbind("dblclick").bind("dblclick",noneeventdblclick);
	jQ("td.hasevent").unbind("click").bind("click",function(event){
		event.stopPropagation();
		jQ(this).find("div").css({backgroundPosition: "0px -32px"});
		myfunc(jQ(this).attr("id"));
	});
}

function myfunc(id){
     var jQid="#"+id;
     if(jQ(jQid).hasClass("filter"))
			return;
		if(!jQ(jQid).hasClass("hasevent")){
			jQ("#td_box_detail").hide();
		}else{
			var text = jQ(jQid).text();
			var box = jQ(jQid).offset();
			var color = jQ(jQid).find("div").css("background-color");			
			var b_iw = jQ("table.invite_day").offset();
			var w_iw = jQ("table.invite_day").width();
			var bg_position = b_iw.left + w_iw;
			var box_position = box.left + jQ("#td_box_detail").width();
			if(box_position>bg_position){
				jQ("#td_box_detail").css({"top":box.top,"left":bg_position - jQ("#td_box_detail").width(),"min-width":jQ(jQid).width()});
				jQ("#td_box_detail div.td_box").css({"background-color":color});
			}
			else{
				jQ("#td_box_detail").css({"top":box.top,"left":box.left,"min-width":jQ(jQid).width()});
				jQ("#td_box_detail div.td_box").css({"background-color":color});
			}
			addDetailContent(jQ(jQid));
			jQ("#td_box_detail div.optdiv a.opt").unbind("click").bind("click",function(){
				jQ("#td_box_detail").hide();
				
				jQ(jQid).find("div").css({backgroundPosition: "0px 0px"});
			});
			jQ("#td_box_detail").show("slow");
			
		}
}
//公共部分
function addDetailContent(trObj){
	var eventid=jQ(trObj).data("eventid");
	var title=jQ(trObj).data("title");
	var eventtype=jQ(trObj).data("eventtype");
	var starttime=jQ(trObj).data("starttime");
	var endtime=jQ(trObj).data("endtime");
	var iswholeday=jQ(trObj).data("iswholeday");
	var address=jQ(trObj).data("address");
	var content=jQ(trObj).data("content");
	var clocktime=eval(jQ(trObj).data("clocktime"));
	var deadlinetime=eval(jQ(trObj).data("deadlinetime"));
	var isvip=eval(jQ(trObj).data("isvip"));
	var reliedclip=eval(jQ(trObj).data("reliedclip"));
	var processstatus=eval(jQ(trObj).data("processstatus"));
	var publishname=jQ(trObj).data("publishname");
	
	var cliptype=eval(jQ(trObj).data("cliptype"));
	
	var forwardname=jQ(trObj).data("forwardname");
	var puid=jQ(trObj).data("puid");
	var fuid=jQ(trObj).data("fuid");
	jQ("#td_box_eventid").val(eventid);
	jQ("#td_box_eventid").data("cliptype",cliptype);
	jQ("#td_box_eventtype").empty().append(getTypeName(eventtype));
	jQ("#td_box_eventtype").prev("span.event").removeClass().addClass("event "+eventtype);
	jQ("#td_box_cliptime").empty();
	if(iswholeday)
		jQ("#td_box_cliptime").append("<span style='width:auto;'>开始于</span><b>"+formateDetailTime(starttime)+"</b>");
	else
		jQ("#td_box_cliptime").append("<b>"+formateDetailTime(starttime)+"</b><b>至</b><b>"+formateDetailTime(endtime)+"</b>");
	if(processstatus==0){
		jQ("#td_box_cliptime").append("<b class=\"edt_ing\">进行中</b>");
	}else if(processstatus==1){
		jQ("#td_box_cliptime").append("<b class=\"edt_over\">已结束</b>");
	}else if(processstatus==2){
		jQ("#td_box_cliptime").append("<b class=\"edt_stop\">已停止</b>");
	}
	jQ("#td_box_title").empty().append(htmlData(title));
	if(reliedclip>0){
		jQ("#td_box_publishname").empty().append("<a href='"+jQ("#ctxVal").val()+"/home/user.html?"+puid+"'>"+publishname+"</a>");
	}else{
		jQ("#td_box_publishname").empty().append(publishname);
	}
	if(fuid>0){
		jQ("#td_box_forwardname").empty().append("<a href='"+jQ("#ctxVal").val()+"/home/user.html?"+fuid+"'>"+forwardname+"</a>").parent().show();
	}else{
		jQ("#td_box_forwardname").empty().parent().hide();
	}
	jQ("#td_box_address").empty().append(htmlData(address));
	jQ("#td_box_content").empty().append(content);
	if(clocktime>0){
		jQ("#td_box_clocktime").empty().append(formateDetailTime(clocktime));
		jQ("#td_box_alert_icon").removeClass().addClass("c_alarm").attr("title","取消提醒");
		jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},cancelClock);
	}else{
		jQ("#td_box_clocktime").empty().append("<i>暂无</i>");
		jQ("#td_box_alert_icon").removeClass().addClass("alarm").attr("title","设置提醒");
		jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},addClock);
	}
	jQ("#td_box_deadlinetime").empty();
	if(deadlinetime>0){
		var systime=eval(jQ("#var_systemtime").val());
		if(deadlinetime<=systime)
			jQ("#td_box_deadlinetime").append("<b>"+formateDetailTime(deadlinetime)+"</b><b class='expire'>已过期</b>");
		else
			jQ("#td_box_deadlinetime").append("<b>"+formateDetailTime(deadlinetime)+"</b>");
	}else{
		jQ("#td_box_deadlinetime").append("<b><i>暂无</i></b>");
	}
	if(isvip==1)
		jQ("#td_box_isvip").addClass("c_import").attr("title","标记为不重要");
	
	else{
		jQ("#td_box_isvip").removeClass("c_import").attr("title","标记为重要");
	}
	if(reliedclip>0){
		if(processstatus==0)
			jQ("#td_box_deve_icon").removeClass().addClass("leave").attr("title","退出档期");
		else
			jQ("#td_box_deve_icon").removeClass().addClass("leave").attr("title","删除档期");
	}else{
		jQ("#td_box_deve_icon").removeClass().addClass("del").attr("title","取消档期");
	}
	jQ("#td_box_setclock").hide();
	jQ("#td_box_showclock").show();
	
	var mobilenotice=eval(jQ("#var_hasmobile").val());
	if(mobilenotice==1){
		jQ(".hasmobilechoose").show();
	}else{
		jQ(".hasmobilechoose").hide();
	}
}
function cancelClock(event){
	var eventid=event.data.eventid;
	var trObj=event.data.trObj;
	jQ.ajax({
		type: "POST",
		url:"eventAjax!cancelClock.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ(trObj).data("clocktime","");
					jQ("#td_box_clocktime").empty().append("<i>暂无</i>");
					jQ("#td_box_alert_icon").removeClass().addClass("alarm").attr("title","设置提醒");
					jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},addClock);
					
				}else{
				}
			}
		}
	});
}
function addClock(event){
	var eventid=event.data.eventid;
	var trObj=event.data.trObj;
	if(jQ("#td_box_showclock").css("display")=="none"){
		jQ("#td_box_setclock").hide();
		jQ("#td_box_showclock").show();
		return;
	}
	jQ("#td_box_showclock").hide();
	jQ("#td_box_setclock input:checkbox").attr("checked","");
	jQ("#td_box_setclock").show();
	
	jQ("#td_box_setclock input.data").val("").datepicker( "destroy" );
	jQ("#alerthour").val(0);
	jQ("#alertmin").val(0);
	jQ("#td_box_setclock input.data").datepicker({
		yearRange : '1950:2020',
		dateFormat:'yy-mm-dd',
		changeMonth:true,
		changeYear:true,
		beforeShow: function(i,e){  
		var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
		e.dpDiv.css('z-index', z);  
	}});
	
	
	jQ("#td_box_setclock button").unbind("click").bind("click",function(){
		var isChecked=eval(jQ("#td_box_setclock input:checkbox").attr("checked"));
		var errzone=jQ("#td_box_setclock_info");
		
			var alertdateval=jQ("#td_box_setclock input:text").val();
			if(alertdateval==null||alertdateval.length<=0){
				errzone.empty();
				errzone.append("请选择提醒的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			
			var alertdate=jQ("#td_box_setclock input:text").datepicker( "getDate" );
			var alerthour=eval(jQ("#alerthour").val());
			var alertmin=eval(jQ("#alertmin").val());
			alertdate.setHours(alerthour);
			alertdate.setMinutes(alertmin);
			var alertlong=alertdate.getTime();
			var nowdate=new Date();
			if(alertlong<nowdate){
				errzone.empty();
				errzone.append("提醒的时间应该是将来的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			var mobilenotice=0;
			if(isChecked&&eval(jQ("#var_hasmobile"))){
				mobilenotice=1;
			}
			jQ.ajax({
				type: "POST",
				url:"eventAjax!addEventClock.action",
				data:{
					eventid:eventid,
					alerttime:alertlong,
					mobilenotice:mobilenotice
				},
			success:function(data){
					
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						jQ("#td_box_setclock").hide();
						jQ("#td_box_showclock").show();
						jQ("#td_box_setclock button").unbind("click");
						
						jQ(trObj).data("clocktime",alertlong);
						jQ("#td_box_clocktime").empty().append(formateDetailTime(alertdate));
						
						jQ("#td_box_alert_icon").removeClass().addClass("c_alarm").attr("title","取消提醒");
						jQ("#td_box_alert_icon").unbind("click").bind("click",{eventid:eventid,trObj:trObj},cancelClock);
					}else{
					}
				}
			}
			});
	});
}
function noeventInCenter(){
	var html="";
	jQ("#crtclip").nextAll().remove();
	jQ("#crtclip").after(html);
	jQ("td.noevent").unbind("dblclick").bind("dblclick",noneeventdblclick);
	jQ("#joinclip").empty();
}
function noneeventdblclick(event){
	var hour=eval(jQ(event.currentTarget).attr("hour"));
	var monthday=eval(jQ("#mouth_fun_weekview_day").val());
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var month=eval(jQ("#mouth_fun_weekview_month").val());
	window.location.href=jQ("#ctxVal").val()+"/myclip/add_clip.html?year="+year+"&month="+(month+1)+"&day="+monthday+"&hour="+hour;
}
function deleteClipEvent(obj){
	var info="";
	var title="";
	if(jQ(obj).hasClass("leave")){
		var cliptype=eval(jQ("#td_box_eventid").data("cliptype"));
		if(cliptype==3){
			info="您确定退出档期么？<p>分享档期将不被保存在回收站内";
		}else
			info="您确定退出档期么？";
		title="退出档期";
	}else if(jQ(obj).hasClass("del")){
		info="您确定取消档期么？";
		title="取消档期";
	}
	var eventid=jQ("#td_box_eventid").val();
	jQ("#viewopt_eventid").val(eventid);
	var opt=jQ("#viewopt");
	opt.bind("deleteEvent",deleteEvent);
	opt.data("function","deleteEvent")
	jQ("#viewopt_p").empty().append(info);
	jQ("#viewopt").dialog( "option", "title",title );
	jQ("#viewopt").dialog("open");
}
function deleteEvent(){
	var eventid=jQ("#viewopt_eventid").val(); 
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					jQ("#viewopt").dialog("close");
					afterDelForHtml(eventid);
					if(jQ("#crtclip").nextAll().length==0&&jQ("#joinclip tr").length==0)
						noeventInCenter();
				}else{
					jQ("#viewopt_p").empty().append(dataObj['msg']);
					jQ("#viewopt").dialog("close");
				}
			}
		}
	});
}

function afterDelForHtml(eventid){
	var startday=eval(jQ("#clipevent-"+eventid).attr("hour"));
	var length=eval(jQ("#clipevent-"+eventid).attr("colspan"));
	var html="";
	for(var i=0;i<length;i++){
		html+="<td class='invite_event noevent' hour="+(startday+i)+" title='双击立即添加档期'><div class='noevent'></div></td>";
	}
	jQ("#clipevent-"+eventid).after(html);
	var tr=jQ("#clipevent-"+eventid).parent();
	jQ("#clipevent-"+eventid).remove();
	if(tr.find("td.noevent").length==tr.find("td").length){
		tr.remove();
	}
	if(jQ("#crtclip").nextAll().length>0&&jQ("#joinclip tr").length>0){
		jQ("#joinclip").addClass("hasshare");
		jQ("#crtclip").parent().addClass("hasjoin");
	}else{
		jQ("#joinclip").removeClass("hasshare");
		jQ("#crtclip").parent().removeClass("hasjoin");
	}
	jQ("td.noevent").unbind("dblclick").bind("dblclick",noneeventdblclick);
}

function buildFun(){
	var html="";
	for(var i=2020;i>=1950;i--){
		html+="<option value='"+i+"'>"+i+"</option>";
	}
	jQ("#mouth_fun_weekview_year").empty().append(html);
	jQ("#td_box_detail").hide();
	jQ("#td_box_detail").unbind("click").bind("click",function(event) {
		event.stopPropagation();
	 });
	
	jQ("#vt_oc_optzone a").click(function(){
		view_fun(jQ(this));
	});
	
	jQ("#viewopt").dialog({
		modal: true,
		bgiframe: true,
		autoOpen: false,
		closeOnEscape:false,
		draggable:false,
		height:200,
		buttons: {
			
			"确定": function() {
				var opt=jQ("#viewopt");
				var triggerfun=opt.data("function");
				opt.trigger(triggerfun);
				opt.removeData("function");
				jQ("#viewopt_p").hide();
				jQ("#viewopt_img").show();
				//activeBtnOnDialog("viewopt",false);
				//jQ(this).dialog('close');
			},
			"取消": function() {
				var viewopt=jQ("#viewopt");
				var triggerfun=jQ("#viewopt").data("function");
				viewopt.unbind(triggerfun);
				viewopt.find("input.eventid").val("");
				viewopt.removeData("function");
				jQ(this).dialog('close');
			}
		},
		close: function() {
			jQ("#viewopt_p").show();
			jQ("#viewopt_img").hide();
		},
		open:function(){
		}
	});
	
	//标记为重要
	jQ("#td_box_isvip").click(function(){
		var eventid=jQ("#td_box_eventid").val();
		if(jQ(this).hasClass("c_import")){
			jQ("#clipevent-"+eventid).data("isvip",0);
			jQ(this).attr("title","标记为不重要");
			setImport(false,eventid);
		}else{
			jQ("#clipevent-"+eventid).data("isvip",1);
			jQ(this).attr("title","标记为重要");
			setImport(true,eventid);
		}
		jQ(this).toggleClass("c_import");
	});
}
function setImportAtLeft(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	var ss=jQ("div.clipevent-"+eventid+" div.isvip span.isvip");
	if(curObj.hasClass("c_import")){
		
		ss.removeClass("c_import").addClass("import");
		ss.attr("title","标记为重要");
		jQ("div.clipevent-"+eventid+" input.isvip").val(0);
		setImport(false,eventid);
	}else if(curObj.hasClass("import")){
		
		ss.removeClass("import").addClass("c_import");
		ss.attr("title","标记为不重要");
		jQ("div.clipevent-"+eventid+" input.isvip").val(1);
		setImport(true,eventid);
	}
}
function addClockAtLeft(event){
	var eventid=jQ(event.currentTarget).parent().prevAll("input.eventid").val();
	var showclock=jQ(event.currentTarget).parent().prevAll("div.show_clock");
	var setclock=jQ(event.currentTarget).parent().prevAll("div.set_clock");
//	var iconObj=jQ(event.currentTarget);
	if(showclock.css("display")=="none"){
		curObj.parent().prevAll("div.set_clock_info").empty().hide();
		setclock.hide();
		showclock.show();
		return;
	}
	showclock.hide();
	setclock.show();
	setclock.find("input:checkbox").attr("checked","true");
	setclock.find("input.data").val("");
	setclock.find("input.alert_hour").val(0);
	setclock.find("input.alert_min").val(0);
	setclock.find("input.data").datepicker({
		yearRange : '1950:2020',
		dateFormat:'yy-mm-dd',
		changeMonth:true,
		changeYear:true,
		beforeShow: function(i,e){  
		var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
		e.dpDiv.css('z-index', z);  
	}});
	
	
	setclock.find("button").unbind("click").bind("click",function(){
		
		var errzone=jQ(this).parent().nextAll("div.set_clock_info");
		var alertdateval=jQ(this).prevAll("input:text").val();
		if(alertdateval==null||alertdateval.length<=0){
			errzone.empty();
			errzone.append("请选择提醒的时间。");
			errzone.show();
			return;
		}else{
			errzone.empty();
		}
		
		var alertdate=jQ(this).prevAll("input:text").datepicker( "getDate" );
		var alerthour=eval(jQ(this).prevAll("div.hourbg").find("input.alert_hour").val());
		var alertmin=eval(jQ(this).prevAll("div.minbg").find("input.alert_min").val());
		alertdate.setHours(alerthour);
		alertdate.setMinutes(alertmin);
		var alertlong=alertdate.getTime();
		var nowdate=new Date();
		if(alertlong<nowdate){
			errzone.empty();
			errzone.append("提醒的时间应该是将来的时间。");
			errzone.show();
			return;
		}else{
			errzone.empty();
		}
		var btnObj=jQ(this);
		jQ.ajax({
			type: "POST",
			url:"eventAjax!addEventClock.action",
			data:{
				eventid:eventid,
				alerttime:alertlong
			},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					
					setclock.hide();
					showclock.show();
					btnObj.unbind("click");
					jQ("div.clipevent-"+eventid+" input.clocktime").val(alertlong);
					var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
					ss.addClass("f_alarm").empty().append(formateDetailTime(alertlong));
					var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
					ss2.removeClass("f_alarm").addClass("f_c_alarm").attr("title","取消提醒");
					ss2.unbind("click").bind("click",cancelClockAtLeft);
				}else{
				}
			}
		}
		});
	});
}
function cancelClockAtLeft(event){
	var eventid=jQ(event.currentTarget).parent().prevAll("input.eventid").val();
	var setclock=jQ(event.currentTarget).parent().prevAll("div.set_clock");
	var showclock=jQ(event.currentTarget).parent().prevAll("div.show_clock");
	var iconObj=jQ(event.currentTarget);
	jQ.ajax({
		type: "POST",
		url:"eventAjax!cancelClock.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj['result']){
					setclock.hide();
					showclock.show();
					jQ("div.clipevent-"+eventid+" input.clocktime").val(0);
					var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
					ss.removeClass("f_c_alarm").empty().append("<i>暂无</i>");
					var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
					ss2.removeClass("f_c_alarm").addClass("f_alarm").attr("title","设置提醒");
					ss2.unbind("click").bind("click",addClockAtLeft);
				}else{
					
				}
			}
		}
	});
}
function controlClockAtRight(event){
	var curObj=jQ(event.currentTarget);
	if(curObj.hasClass("f_alarm")){
		//addClock
		var eventid=curObj.parent().prevAll("input.eventid").val();
		var showclock=curObj.parent().prevAll("div.show_clock");
		var setclock=curObj.parent().prevAll("div.set_clock");
//		var iconObj=jQ(event.currentTarget);
		if(showclock.css("display")=="none"){
			curObj.parent().prevAll("div.set_clock_info").empty().hide();
			setclock.hide();
			showclock.show();
			return;
		}
		showclock.hide();
		setclock.show();
		setclock.find("input.data").val("");
		setclock.find("input.alert_hour").val(0);
		setclock.find("input.alert_min").val(0);
		setclock.find("input.data").datepicker({
			yearRange : '1950:2020',
			dateFormat:'yy-mm-dd',
			changeMonth:true,
			changeYear:true,
			beforeShow: function(i,e){  
			var z = jQuery(i).closest(".ui-dialog").css("z-index") + 4;  
			e.dpDiv.css('z-index', z);  
		}});
		
		
		setclock.find("button").unbind("click").bind("click",function(){
			
			var errzone=jQ(this).parent().nextAll("div.set_clock_info");
			var alertdateval=jQ(this).prevAll("input:text").val();
			if(alertdateval==null||alertdateval.length<=0){
				errzone.empty();
				errzone.append("请选择提醒的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			
			var alertdate=jQ(this).prevAll("input:text").datepicker( "getDate" );
			var alerthourobj=jQ(this).prevAll("div.hourbg").find("input.alert_hour")
			var alertminobj=jQ(this).prevAll("div.minbg").find("input.alert_min")
			var alerthour=eval(alerthourobj.val());
			var alertmin=eval(alertminobj.val());
			alertdate.setHours(alerthour);
			alertdate.setMinutes(alertmin);
			var alertlong=alertdate.getTime();
			var nowdate=new Date();
			if(alertlong<nowdate){
				errzone.empty();
				errzone.append("提醒的时间应该是将来的时间。");
				errzone.show();
				return;
			}else{
				errzone.empty();
			}
			setclock.hide();
			var mobilenotice=0;
			var checked=eval(jQ(this).prevAll("input:checkbox").attr("checked"));
			if(eval(jQ("#var_hasmobile"))&&checked){
				mobilenotice=1;
			}
			var btnObj=jQ(this);
			jQ.ajax({
				type: "POST",
				url:"eventAjax!addEventClock.action",
				data:{
					eventid:eventid,
					alerttime:alertlong,
					mobilenotice:mobilenotice
				},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						showclock.show();
						alerthourobj.val(0);
						alertminobj.val(0);
						btnObj.unbind("click");
						jQ("div.clipevent-"+eventid+" input.clocktime").val(alertlong);
						var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
						ss.addClass("alarm").empty().append(formateDetailTime(alertlong));
						var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
						ss2.removeClass("f_alarm").addClass("f_c_alarm").attr("title","取消提醒");
						ss2.unbind("click").bind("click",cancelClockAtLeft);
					}else{
					}
				}
			}
			});
		});
	}else if(curObj.hasClass("f_c_alarm")){
		//cancelClock
		var eventid=jQ(event.currentTarget).parent().prevAll("input.eventid").val();
		var setclock=jQ(event.currentTarget).parent().prevAll("div.set_clock");
		var showclock=jQ(event.currentTarget).parent().prevAll("div.show_clock");
		var iconObj=jQ(event.currentTarget);
		jQ.ajax({
			type: "POST",
			url:"eventAjax!cancelClock.action",
			data:{
				eventid:eventid
			},
			success:function(data){
				if(data!=null){
					var dataObj=eval("("+data+")");//转换为json对象
					if(dataObj['result']){
						setclock.hide();
						showclock.show();
						jQ("div.clipevent-"+eventid+" input.clocktime").val(0);
						var ss=jQ("div.clipevent-"+eventid+" div.show_clock span.clockval");
						ss.removeClass("alarm").empty().append("<i>暂无</i>");
						var ss2=jQ("div.clipevent-"+eventid+" div.opt_item a.alarmicon");
						ss2.removeClass("f_c_alarm").addClass("f_alarm").attr("title","设置提醒");
						ss2.unbind("click").bind("click",addClockAtLeft);
					}else{
						
					}
				}
			}
		});
	}
}
function formateDetailTime(daytime){
	var temp=new Date();
	temp.setTime(daytime);
	return temp.pattern("yyyy-MM-dd HH:mm");
}
function ignoreInvitedClip(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!ignoreInvitedClip.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					invitingOptReturnBox(event.currentTarget,"忽略的档期已放入回收站");
					jQ("div").remove(".clipevent-"+eventid);
					noeventInvitedClips();
				}
			}
		}
	});
}
function acceptInvitedClip(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	var year=eval(jQ("#mouth_fun_weekview_year").val());
	var month=eval(jQ("#mouth_fun_weekview_month").val());
	var day=eval(jQ("#mouth_fun_weekview_day").val());
	jQ.ajax({
		type: "POST",
		url:"dayAjax!acceptInvitedClip.action",
		data:{
			eventid : eventid,
			year : year,
			month : month,
			day : day
		},
		success:function(data){
			if(jQ(data).find("eventid").length>0){
				invitingOptReturnBox(event.currentTarget,"接收邀请成功");
				var eventid=jQ(data).find("eventid").text();//
				jQ("div").remove(".clipevent-"+eventid);
				noeventInvitedClips();
				var title=jQ(data).find("title").text();//
				var eventtype=jQ(data).find("eventtype").text();//
				var iscrtday=eval(jQ(data).find("iscrtday").text());
				if(iscrtday){
					var startday=eval(jQ(data).find("startday").text());//
					var endday=eval(jQ(data).find("endday").text());//
					var processstatus=eval(jQ(data).find("processstatus").text());
					var htmljoin="";
					htmljoin+="<tr>";
//					htmljoin+="<input type='hidden' value='"+iscrtweek+"' class='iscrtweek'/>";
//					htmljoin+="<input type='hidden' value='"+istoday+"' class='istoday'/>";
//					htmljoin+="<input type='hidden' value='"+istommorrow+"' class='istommorrow'/>";
					for(var i=0;i<startday;i++){
						htmljoin+="<td class='invite_event noevent' title='双击立即添加档期' hour='"+i+"'><div class='noevent'></div></td>";
					}
					htmljoin+="<td class='invite_event my_join hasevent' id='clipevent-"+eventid+"' hour='"+startday+"' colspan='"+(endday-startday)+"'>";
					htmljoin+="<div class='hasevent'>";
					if(processstatus==2)
						htmljoin+="<a class='stop filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
					else
						htmljoin+="<a class='"+eventtype+" filteeventtype-"+eventtype+"'>"+htmlData(title)+"</a></div></td>";
					for(var i=0;i<jQ("#crtclip td").length-endday;i++){
						htmljoin+="<td class='invite_event noevent' title='双击立即添加档期' hour='"+(endday+1+i)+"'><div class='noevent'></div></td>";
					}
					htmljoin+="</tr>";
					jQ("#joinclip").append(htmljoin);
					//jQ("tr.noevent").remove();
					if(jQ("#crtclip").nextAll().length>0&&jQ("#joinclip tr").length>0){
						jQ("#joinclip").addClass("hasshare");
						jQ("#crtclip").parent().addClass("hasjoin");
					}else{
						jQ("#joinclip").removeClass("hasshare");
						jQ("#crtclip").parent().removeClass("hasjoin");
					}
					var starttime=eval(jQ(data).find("starttime").text());
					var endtime=eval(jQ(data).find("endtime").text());
					var address=jQ(data).find("address").text();
					var content=jQ(data).find("content").text();
					var clocktime=eval(jQ(data).find("clocktime").text());
					var deadlinetime=eval(jQ(data).find("deadlinetime").text());
					var isvip=eval(jQ(data).find("isvip").text());
					var reliedclip=eval(jQ(data).find("reliedclip").text());
					var publishname=jQ(data).find("publishname").text();
					jQ("#clipevent-"+eventid).data("eventid",eventid);
					jQ("#clipevent-"+eventid).data("title",title);
					jQ("#clipevent-"+eventid).data("eventtype",eventtype);
					jQ("#clipevent-"+eventid).data("starttime",starttime);
					jQ("#clipevent-"+eventid).data("endtime",endtime);
					jQ("#clipevent-"+eventid).data("address",address);
					jQ("#clipevent-"+eventid).data("content",content);
					jQ("#clipevent-"+eventid).data("clocktime",clocktime);
					jQ("#clipevent-"+eventid).data("deadlinetime",deadlinetime);
					jQ("#clipevent-"+eventid).data("isvip",isvip);
					jQ("#clipevent-"+eventid).data("processstatus",processstatus);
					jQ("#clipevent-"+eventid).data("reliedclip",reliedclip);
					jQ("#clipevent-"+eventid).data("publishname",publishname);
					effectEventDetail();
				}
				
				
				
			}
		}
	});
}

function invitingOptReturnBox(obj,content){
	var obj_box = jQ(obj);
	var obj_offset = obj_box.offset();
	var msg_box = jQ("#accept_msg_box");
	jQ("#accept_msg_box_content").empty().append(content);
	var _top = obj_offset.top - msg_box.outerHeight() - 10;
	var _left = obj_offset.left - msg_box.outerHeight()/2;
	msg_box.css({"top":_top+"px","left":_left+"px"}).show();
	msg_box.find("div.msg_note").animate({top: 20+'px'}, 500,function(){
		setTimeout(function(){
			msg_box.find("div.msg_note").animate({top: 100+'px'},500,function(){msg_box.hide();});
		},2000);
	});
}

function delInvitedClip(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	jQ.ajax({
		type: "POST",
		url:"eventAjax!deleteEvent.action",
		data:{
			eventid:eval(eventid)
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					invitingOptReturnBox(event.currentTarget,"取消的档期已放入回收站");
					jQ("div").remove(".clipevent-"+eventid);
					noeventInvitedClips();
				}
			}
		}
	});
}

function refuseInvitedClip(event){
	var curObj=jQ(event.currentTarget);
	var eventid=eval(curObj.parent().prevAll("input.eventid").val());
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!refuseInvitedClip.action",
		data:{
			eventid:eventid
		},
		success:function(data){
			if(data!=null){
				var dataObj=eval("("+data+")");//转换为json对象
				if(dataObj.result){
					invitingOptReturnBox(event.currentTarget,"拒绝的档期已放入回收站");
					jQ("div").remove(".clipevent-"+eventid);
					noeventInvitedClips();
				}
			}
		}
	});
}
function getTypeName(eng){
	if(eng=='other'){
		return "其他";
	}else if(eng=='work'){
		return "工作";
	}else if(eng=='socal'){
		return "社交";
	}else if(eng=='sect'){
		return "私人";
	}
}
function noeventInvitedClips(){
	var html="";
	var lastlength=jQ("#last_clip_zone div.me_list").length;
	var urgentlength=jQ("#urgent_clip_zone div.me_list").length;
	if(lastlength==0){
		html="<div class='empty_list'><span class=title'><i>暂无邀请</i></span></div>";
		jQ("#last_clip_zone").empty().append(html);
		jQ("#new b.msgcount24").hide();
	}else{
		jQ("#new b.msgcount24").show().empty().append(lastlength);
	}
	html="";
	if(urgentlength==0){
		html="<div class='empty_list'><span class=title'><i>暂无邀请</i></span></div>";
		jQ("#urgent_clip_zone").empty().append(html);
		jQ("#urgent b.msgcountj").hide();
	}else{
		jQ("#urgent b.msgcountj").show().empty().append(urgentlength);
	}
}
//滚动定位
function fun_scroll(){
	var html_height = jQ("html").height();	
	jQ("div.invite_page").css({"min-height":html_height-200});
	jQ("div.me_box").css({"max-height":html_height-260});
	jQ("div.view_con").css({"max-height":html_height-225});
}
/**
 * * timeattr 
 * 1:最近24个邀请档期
 * 2:最急的24小时内的档期
 * */
function getEventsByInviting(){
	jQ.ajax({
		type: "POST",
		url:"manageClipAjax!getEventsByInviting.action",
		success:function(data){
			var htmlurgent="";
			var htmllast="";
			var mobilenotice=eval(jQ(data).find("mobilenotice").text());
			jQ(data).find("EventForView").each(function(){
				var eventid=jQ(this).attr("id");
				var title=jQ(this).find("title").text();
				var eventtype=jQ(this).find("eventtype").text();
				var starttime=eval(jQ(this).find("starttime").text());
				var endtime=eval(jQ(this).find("endtime").text());
				var iswholeday=eval(jQ(this).find("iswholeday").text());
				var address=jQ(this).find("address").text();
				var clocktime=eval(jQ(this).find("clocktime").text());
				var deadlinetime=eval(jQ(this).find("deadlinetime").text());
				var isexpire=eval(jQ("isexpire",this).text());
				var isvip=eval(jQ(this).find("isvip").text());
				var timeattr=eval(jQ(this).attr("timeattr"));
				var processstatus=eval(jQ(this).find("processstatus").text());
				var reliedclip=eval(jQ(this).find("reliedclip").text());
				var publishname=jQ(this).find("publishname").text();
				var puid=jQ(this).find("puid").text();
				var tmp="";
				tmp+="<div class='me_list clipevent-"+eventid+"'>";
				tmp+="<input type='hidden' class='eventid' value='"+eventid+"'>";
				tmp+="<input type='hidden' class='clocktime' value='"+clocktime+"'>";
				tmp+="<input type='hidden' class='isvip' value='"+isvip+"'>";
				tmp+="<div class='me_item isvip'>";
				tmp+="<span class='e_"+eventtype+"' title='"+getTypeName(eventtype)+"'></span>";
				tmp+="<span class='title'>"+htmlData(title)+"</span>";
				if(isvip)
					tmp+="<span class='c_import isvip' title='标记为不重要'></span>";
				else
					tmp+="<span class='import isvip' title='标记为重要'></span>";
				tmp+="</div><div class='me_item'>";
				tmp+="<span>发起人：</span><span><a href='"+jQ("#ctxVal").val()+"/home/user.html?"+puid+"'>"+publishname+"</a></span>";
				tmp+="</div><div class='me_item'>";
				if(iswholeday)
					tmp+="<span class='time'><span>开始于：</span><b>"+formateDetailTime(starttime)+"</b></span>";
				else
					tmp+="<span class='time'><b>"+formateDetailTime(starttime)+"</b><i>-</i><b>"+formateDetailTime(endtime)+"</b></span>";
				if(processstatus==0){
					tmp+="<b class='edt_ing'>进行中</b>";
				}else if(processstatus==1){
					tmp+="<b class=\"edt_over\">已结束</b>";
				}else if(processstatus==2){
					tmp+="<b class=\"edt_stop\">已停止</b>";
				}
				tmp+="</div><div class='me_item'>";
				tmp+="<span>截止：</span><span>";
				if(deadlinetime>0){
					tmp+=formateDetailTime(deadlinetime);
					if(isexpire)
						tmp+="<b class='expire'>已过期</b>";	
				}
				else
					tmp+="<i>暂无</i>";
				tmp+="</span>";
				tmp+="</div><div class='me_item'>";
				tmp+="<span>地址：</span><span class='adr'>"+htmlData(address)+"</span>";
				tmp+="</div><div class='me_item me_clock show_clock'>";
				tmp+="<span>提醒：</span>";
				if(clocktime>0){
					tmp+="<span class='alarm clockval'>"+formateDetailTime(clocktime);
				}else{
					tmp+="<span class='clockval'><i>暂无</i>";
				}
				tmp+="</span>";
				tmp+="</div><div class='me_item me_clock set_clock' style='display:none;'>";
				tmp+="<span>提醒：</span>";
				tmp+="<input style='margin:0 5px;width:130px;' type='text' size='15' class='data'>";
				tmp+="<div class='timebg hourbg'><a class='minus' onclick='hourminus(jQ(this).next());'></a>" +
						"<input maxlength='2' value='0' onblur='hourinput(this);' class='alert_hour'/>" +
						"<a class='plus' onclick='hourplus(jQ(this).prev());'></a></div>" +
						"<span class='tipt'>时</span>";
				tmp+="<div class='timebg minbg'><a class='minus' onclick='minminus(jQ(this).next());'></a>" +
						"<input maxlength='2' value='0' onblur='mininput(this);' class='alert_min'/>" +
						"<a class='plus' onclick='minplus(jQ(this).prev());'></a></div>" +
						"<span class='tipt'>分</span>";
				if(mobilenotice)
					tmp+="<input type='checkbox' class='hasmobilechoose' style='float:left;margin-top:8px;' checked='checked'/><img src='"+jQ("#ctxVal").val()+"/image/mobilemsg.png' width='16px' height='16px' style='float:left;margin-top:5px;' class='hasmobilechoose' alt='手机短信提醒' title='手机短信提醒'/>";
				tmp+="<button >确定</button></div><div class='me_item set_clock_info' style='color:#ff0000;'></div><div class='me_item opt_item'>";
				tmp+="<a class='f_info' title='档期详情'></a>";
				if(processstatus==0){
					tmp+="<a class='f_refuse' title='拒绝邀请'></a>";
					tmp+="<a class='f_ignore' title='忽略邀请'></a>";
					tmp+="<a class='f_accept' title='接受邀请'></a>";
				}else{
					tmp+="<a class='f_del' title='删除档期'></a>";
				}
				if(clocktime>0){
					tmp+="<a class='alarmicon f_c_alarm' title='取消提醒' ></a>";
				}else{
					tmp+="<a class='alarmicon f_alarm' title='设置提醒' ></a>";
				}
				tmp+="</div></div>";
				
				if(timeattr==1){
					htmllast+=tmp;
				}else if(timeattr==2){
					htmlurgent+=tmp;
				}
			});
			jQ("#last_clip_zone").empty().append(htmllast);
			jQ("#urgent_clip_zone").empty().append(htmlurgent);
			noeventInvitedClips();
			jQ("#urgent_clip_zone").hide();
			jQ("#invite_clip_zone div div.isvip span.isvip").click(function(event){
				var curObj=jQ(event.currentTarget);
				var eventid=eval(curObj.parent().prevAll("input.eventid").val());
				var ss=jQ("div.clipevent-"+eventid+" div.isvip span.isvip");
				if(curObj.hasClass("c_import")){
					
					ss.removeClass("c_import").addClass("import");
					ss.attr("title","标记为重要");
					jQ("div.clipevent-"+eventid+" input.isvip").val(0);
					setImport(false,eventid);
				}else if(curObj.hasClass("import")){
					
					ss.removeClass("import").addClass("c_import");
					ss.attr("title","标记为不重要");
					jQ("div.clipevent-"+eventid+" input.isvip").val(1);
					setImport(true,eventid);
				}
			});
			jQ("#invite_clip_zone div div.me_item a.f_info").click(function(event){
				var curObj=jQ(event.currentTarget);
				var eventid=eval(curObj.parent().prevAll("input.eventid").val());
				window.location.href=jQ("#ctxVal").val()+"/myclip/clip_detail.html?eventid="+eventid;
			});
			jQ("#invite_clip_zone div div.me_item a.f_del").unbind("click").bind("click",delInvitedClip);
			jQ("#invite_clip_zone div div.me_item a.f_refuse").unbind("click").bind("click",refuseInvitedClip);
			jQ("#invite_clip_zone div div.me_item a.f_accept").unbind("click").bind("click",acceptInvitedClip);
				
			jQ("#invite_clip_zone div div.me_item a.f_ignore").unbind("click").bind("click",ignoreInvitedClip);
			
			jQ("#invite_clip_zone div div.me_item a.alarmicon").unbind("click").bind("click",controlClockAtRight);
//			jQ("#invite_clip_zone div div.me_item a.f_alarm").unbind("click").bind("click",addClockAtLeft);
			//jQ("#invite_clip_zone div div.me_item span.isvip").unbind("click").bind("click",setImportAtLeft);
		}
	});
}
function setImport(isImport,eventid){
	jQ.ajax({
		type: "POST",
		url:"eventAjax!setEventImport.action",
		data:{
			isImport:Number(isImport),
			eventid:eval(eventid)
		},
		success:function(data){
		}
	});
}
//右边栏特效
function view_fun(obj){
//	if(jQ(obj).hasClass("onit")){
//		jQ("div.view_con").animate({"width":"0px"},"slow",function(){
//			jQ("div.view_con").css("border-width","0");
//			jQ(obj).removeClass("onit");
//		});
//		jQ("div.view_fun").animate({"width":"50px"},"slow");
//		jQ("div.vf_invite").children("div").hide();
//	}
//	else{
		var effectcolor=jQ(obj).attr("borderc");
		jQ("div.view_con").css("border","1px solid #"+effectcolor);
//		if(!jQ("div.vt_oc a").hasClass("onit")){
//			jQ("div.view_fun").animate({"width":"305px"},"slow",function(){
//				jQ("div.view_con").animate({"width":"257px","border-width":"1px"},"slow");
//			});
//		}
		var effectid=jQ(obj).attr("effectzone");
		jQ("div.vf_invite").children("div").hide();
		jQ("#"+effectid).show();
		jQ("#vt_oc_optzone a").removeClass("onit");
		jQ(obj).addClass("onit");
//	}
}

function filterEvent(obj,typename){
	var flag=eval(jQ(obj).attr("checked"));
	var tdobj;
	if(typename=='other'){
		tdobj=jQ("a.filteeventtype-other").parent();
		jQ("div.filter-other input:checkbox").attr("checked",flag);
	}else if(typename=='work'){
		tdobj=jQ("a.filteeventtype-work").parent();
		jQ("div.filter-work input:checkbox").attr("checked",flag);
	}else if(typename=='socal'){
		tdobj=jQ("a.filteeventtype-socal").parent();
		jQ("div.filter-socal input:checkbox").attr("checked",flag);
	}else if(typename=='sect'){
		tdobj=jQ("a.filteeventtype-sect").parent();
		jQ("div.filter-sect input:checkbox").attr("checked",flag);
	}else if(typename=='import'){
		jQ("div.filter-import input:checkbox").attr("checked",flag);
		tdobj=jQ("input.filteisvip[value='0']").parent();
	}else if(typename=='c_import'){
		jQ("div.filter-c_import input:checkbox").attr("checked",flag);
		tdobj=jQ("input.filteisvip[value='1']").parent();
	}
	if(flag){
		tdobj.removeClass("filter");
		tdobj.parent().each(function(){
			if(jQ(this).find("td").length>jQ(this).find("td.filter").length+jQ(this).find("td.noevent").length){
				jQ(this).show();
			}
		});
	}else{
		tdobj.addClass("filter");
		tdobj.parent().each(function(){
			if(jQ(this).find("td").length==jQ(this).find("td.filter").length+jQ(this).find("td.noevent").length){
				jQ(this).hide();
			}
		});
	}
}